<template>
  <div class="reports-container">
    <el-card>
      <div id="main" style="width:6200px;height:500px">
    </div>
    </el-card>

  </div>
</template>

<script>
import * as Echarts from 'echarts'
import { getData } from '@/api/login.js'
export default {
  name: 'reports',
  data () {
    return {
      option: {
        title: {
          text: '用户来源'
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#E9EEF3'
            }
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        yAxis: [
          {
            type: 'value'
          }
        ]
      }
    }
  },
  async mounted () {
    // 两个异步操作 不会等着另一个执行完毕才执行 有await会等着上一个操作执行完再执行
    const res = await getData()
    console.log(res)
    this.option = { ...this.option, ...res.data.data }
    var chartDom = document.getElementById('main')
    var myChart = Echarts.init(chartDom)
    this.option && myChart.setOption(this.option)
  },
  created () {

  }
}
</script>

<style>
</style>
